package DesignModel.Singleton;

/*
 * Author: JacksonCoder
 * FileName: DatabaseConnectionPool
 * Version: 1.0.0
 * Date: 2025/2/27
 */

public class DatabaseConnectionPool {

    // 静态实例变量
    private static volatile DatabaseConnectionPool instance;

    // 私有构造函数
    private DatabaseConnectionPool() {
        // 初始化连接池
        System.out.println("DatabaseConnectionPool initialized");
    }

    // 全局访问点
    public static DatabaseConnectionPool getInstance() {
        if(instance == null){
            synchronized (DatabaseConnectionPool.class){
                if(instance == null){
                    instance = new DatabaseConnectionPool();
                }
            }
        }

        return instance;
    }

    // 模拟获取连接的方法
    public void getConnection(){
        System.out.println("Getting a database connection...");
    }

}
